VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
Object = "{B3FB64BF-91F9-11D7-A482-0008A14158BC}#2.22#0"; "ITGControls.ocx"
Begin VB.Form frmReportPickList 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Report Pick List"
   ClientHeight    =   3195
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   4515
   ControlBox      =   0   'False
   LinkTopic       =   "Form1"
   LockControls    =   -1  'True
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   3195
   ScaleWidth      =   4515
   Begin ITGControls.ITGCommandButton ITGCommandButton2 
      Height          =   375
      Left            =   3060
      TabIndex        =   2
      Top             =   2760
      Width           =   1395
      _ExtentX        =   2461
      _ExtentY        =   661
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Caption         =   "Cancel"
   End
   Begin ITGControls.ITGCommandButton ITGCommandButton1 
      Height          =   375
      Left            =   1620
      TabIndex        =   1
      Top             =   2760
      Width           =   1395
      _ExtentX        =   2461
      _ExtentY        =   661
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Caption         =   "Ok"
   End
   Begin MSComctlLib.ListView lvwList 
      Height          =   2775
      Left            =   -60
      TabIndex        =   0
      Top             =   -60
      Width           =   4605
      _ExtentX        =   8123
      _ExtentY        =   4895
      View            =   3
      LabelEdit       =   1
      LabelWrap       =   0   'False
      HideSelection   =   -1  'True
      FullRowSelect   =   -1  'True
      _Version        =   393217
      ForeColor       =   -2147483640
      BackColor       =   -2147483643
      BorderStyle     =   1
      Appearance      =   0
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      NumItems        =   0
   End
End
Attribute VB_Name = "frmReportPickList"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Form_Load()
    cID = ""
    cName = ""
    FormCenter frmReportPickList, ITGLedgerMain
    DataToPick
End Sub

Private Sub Form_Unload(Cancel As Integer)
    Set frmReportPickList = Nothing
End Sub

Private Sub ITGCommandButton1_Click()
    SelectOK
End Sub

Private Sub ITGCommandButton2_Click()
    Unload Me
End Sub
Private Sub DataToPick()
    Select Case cReport
            Case "Unserved_Sales_Order"
                    'GetSalesORderID
                    GetReportID "SELECT cSONo as ID, B.cName as Name " & _
                                "FROM SO A Left Outer Join Client_Customer B On A.cCode = B.cCode " & _
                                "WHERE A.cCompanyID = '" & Trim(COID) & "' ORDER BY cSONo", "S.O. ID", "Customer"
            Case "Sales_Order_Delivered"
                    'GetDeliveryID
                    GetReportID "SELECT cDRNo as id, dDate as name " & _
                                "FROM DR A  " & _
                                "WHERE A.cCompanyID = '" & Trim(COID) & "' And " & _
                                "      dDate Between '" & frmReportConditioner.dtITGDateFrom.Text & "' And '" & frmReportConditioner.dtITGDateTo.Text & "' " & _
                                "ORDER BY cDRNo", "D.R. ID", "Date"
            Case "Invoiced_Sales_Order"
                    'GetSalesORderID
                    GetReportID "SELECT cSONo as ID, B.cName as Name " & _
                                "FROM SO A Left Outer Join Client_Customer B On A.cCode = B.cCode " & _
                                "WHERE A.cCompanyID = '" & Trim(COID) & "' And " & _
                                "      A.dDate Between '" & frmReportConditioner.dtITGDateFrom.Text & "' And '" & frmReportConditioner.dtITGDateTo.Text & "' " & _
                                "ORDER BY cSONo", "S.O. ID", "Customer"
            Case "Sales_Journal_Customer"
                    'GetCustomerID
                    GetReportID "SELECT cCode as ID, cName as Name " & _
                                "FROM Client_Customer " & _
                                "WHERE cCompanyID = '" & Trim(COID) & "' ORDER BY cCode", "Customer ID", "Name"
            Case "Sales_Journal_Salesman"
                    'GetSalesmanID
                    GetReportID "SELECT cCode as ID, cName as Name " & _
                                "FROM Salesman " & _
                                "WHERE cCompanyID = '" & Trim(COID) & "' ORDER BY cCode", "Salesman ID", "Name"
            Case "Sales_Journal_Product"
                    'GetProductID
                    GetReportID "SELECT cItemno as ID, cDesc as Name " & _
                                "FROM Item A  " & _
                                "WHERE A.cCompanyID = '" & Trim(COID) & "' ORDER BY cItemNo", "Product ID", "Description"
            Case "Sales_Journal_Market_Segment"
                    'GetMarketSegmentID
                    GetReportID "SELECT cMSCode as ID, cName as Name " & _
                                "FROM Sales A Left Outer Join Client_Customer B On A.cCode = B.cCode " & _
                                "WHERE A.cCompanyID = '" & Trim(COID) & "' ORDER BY cMSCode ", "Market Segment ID", "Name"
            Case "Return_Sales_Customer"
                    'GetCustomerID
                    GetReportID "SELECT cCode as ID, cName as Name " & _
                                "FROM Client_Customer " & _
                                "WHERE cCompanyID = '" & Trim(COID) & "' ORDER BY cCode", "Customer ID", "Name"
            Case "Return_Sales_Salesman"
                    'GetSalesmanID
                    GetReportID "SELECT cCode as ID, cName as Name " & _
                                "FROM Salesman " & _
                                "WHERE cCompanyID = '" & Trim(COID) & "' ORDER BY cCode", "Salesman ID", "Name"
            Case "Return_Sales_Product"
                    'GetProductID
                    GetReportID "SELECT cItemno as ID, cDesc as Name " & _
                                "FROM Item A  " & _
                                "WHERE A.cCompanyID = '" & Trim(COID) & "' ORDER BY cItemNo", "Product ID", "Description"
            Case "Return_Sales_Invoice"
                    'GetReturnInvoiceID
                    GetReportID "SELECT cInvno as ID, dDate as Name " & _
                                "FROM RSales " & _
                                "WHERE cCompanyID = '" & Trim(COID) & "' And " & _
                                "      dDate Between '" & frmReportConditioner.dtITGDateFrom.Text & "' And '" & frmReportConditioner.dtITGDateTo.Text & "' " & _
                                "ORDER BY cInvno", "Invoice ID", "Date"
            Case "Collection_OR_Number"
                    'GetCollectionID
                    GetReportID "SELECT cTranno as id, dDate as Name " & _
                                "FROM PR " & _
                                "WHERE cCompanyID = '" & Trim(COID) & "' And " & _
                                "      dDate Between '" & frmReportConditioner.dtITGDateFrom.Text & "' And '" & frmReportConditioner.dtITGDateTo.Text & "' " & _
                                "ORDER BY cTranno ", "Collection ID", "Date"
            Case "Collection_Customer"
                    'GetCustomerID
                    GetReportID "SELECT cCode as ID, cName as Name " & _
                                "FROM CLIENT_CUSTOMER " & _
                                "WHERE cCompanyID = '" & Trim(COID) & "' ORDER BY cCode", "Customer ID", "Name"
            Case "Collection_Invoice"
                    'GetCollectionID
                    GetReportID "SELECT cTranno as id, dDate as Name " & _
                                "FROM PR " & _
                                "WHERE cCompanyID = '" & Trim(COID) & "' And " & _
                                "      dDate Between '" & frmReportConditioner.dtITGDateFrom.Text & "' And '" & frmReportConditioner.dtITGDateTo.Text & "' " & _
                                "ORDER BY cTranno ", "Collection ID", "Date"
            Case "Collection_Salesman"
                    'GetSalesmanID
                    GetReportID "SELECT cCode as ID, cName as Name " & _
                                "FROM Salesman " & _
                                "WHERE cCompanyID = '" & Trim(COID) & "' ORDER BY cCode", "Salesman ID", "Name"
            Case "Collection_Market_Segment"
                    'GetMarketSegmentID
                    GetReportID "SELECT cMSCode as ID, cName as Name " & _
                                "FROM Sales A Left Outer Join CLIENT_CUSTOMER B On A.cCode = B.cCode " & _
                                "WHERE A.cCompanyID = '" & Trim(COID) & "' ORDER BY cMSCode ", "Market Segment ID", "Name"
            Case "Collection_Check"
                    GetReportID "Select Distinct A.cCheckno as ID, cBankName as Name " & _
                                "from PR_C A Left Outer Join PR B On A.cTranno = B.cTranno " & _
                                            "Left Outer Join Bank C On A.cBankID = C.cBankID " & _
                                            "Left Outer Join PR_Map D On A.cTranno =  D.cTranno " & _
                                "Where cType = 'CHK' and A.cCompanyID = '" & Trim(COID) & "' " & _
                                "Order by A.cCheckno ", "Check Number", "Bank Name"
            Case "Pulled_Out_Checks"
                    GetReportID "Select cCheckno as id, dCheckDate as Name " & _
                                "From Pulled_T A Left Outer Join Pulled B On A.cTranno = B.cTranno " & _
                                "Where dDate Between '" & frmReportConditioner.dtITGDateFrom.Text & "' And '" & frmReportConditioner.dtITGDateTo.Text & "'", "Check Number", "Check Date"
                                
            Case "Customer_Credit_Balance"
                    GetReportID "SELECT cCode as ID, cName as Name " & _
                                "FROM CLIENT_CUSTOMER " & _
                                "WHERE cCompanyID = '" & Trim(COID) & "' ORDER BY cCode", "Customer ID", "Name"
            Case "Purchase_Journal_Supplier"
                    'GetSupplierID
                    GetReportID "SELECT cCode as ID, cName as Name " & _
                                "FROM Client_Supplier " & _
                                "WHERE cCompanyID = '" & Trim(COID) & "' ORDER BY cCode", "Supplier ID", "Name"
            Case "Purchase_Journal_Product"
                    'GetProductID
                    GetReportID "SELECT cItemno as ID, cDesc as Name " & _
                                "FROM Item A  " & _
                                "WHERE A.cCompanyID = '" & Trim(COID) & "' ORDER BY cItemNo", "Product ID", "Description"
            Case "Purchase_Journal_Invoice"
                    'GetPurchaseInvoiceID
                    GetReportID "SELECT cInvno as ID, dDate as Name " & _
                                "FROM PURInvoice " & _
                                "WHERE cCompanyID = '" & Trim(COID) & "' And " & _
                                "      dDate Between '" & frmReportConditioner.dtITGDateFrom.Text & "' And '" & frmReportConditioner.dtITGDateTo.Text & "' " & _
                                "ORDER BY cInvno", "Invoice ID", "Date"
            Case "Purchase_Return_Supplier"
                    'GetSupplierID
                    GetReportID "SELECT cCode as ID, cName as Name " & _
                                "FROM Client_Supplier " & _
                                "WHERE cCompanyID = '" & Trim(COID) & "' ORDER BY cCode", "Supplier ID", "Name"
            Case "Purchase_Return_Product"
                    'GetProductID
                    GetReportID "SELECT cItemno as ID, cDesc as Name " & _
                                "FROM Item A  " & _
                                "WHERE A.cCompanyID = '" & Trim(COID) & "' ORDER BY cItemNo", "Product ID", "Description"
            Case "Voucher_Transaction_Number"
                GetReportID "Select cTranno as ID, dDate as Name " & _
                            "From Pay " & _
                            "WHERE cCompanyID = '" & Trim(COID) & "' And " & _
                            "      dDate Between '" & frmReportConditioner.dtITGDateFrom.Text & "' And '" & frmReportConditioner.dtITGDateTo.Text & "' " & _
                            "Order By cTranno", "Transaction ID", "Date"
            Case "Voucher_Journal_Payment"
                    'GetVoucherID
                    GetReportID "SELECT cTranno as ID, cName as Name " & _
                                "FROM ( " & _
                                     "SELECT cTranno, cName " & _
                                     "FROM Voucher " & _
                                     "WHERE cCompanyID = '" & Trim(COID) & "' " & _
                                     "UNION ALL " & _
                                     "SELECT cTranno, cName " & _
                                     "FROM VOUTPC " & _
                                     "WHERE cCompanyID = '" & Trim(COID) & "') A " & _
                                "ORDER BY cTranno", "Voucher ID", "Payment To"
            Case "Voucher_Journal_Summary"
                    'GetVoucherID
                    GetReportID "SELECT cTranno as ID, cName as Name " & _
                                "FROM ( " & _
                                     "SELECT cTranno, cName " & _
                                     "FROM Voucher " & _
                                     "WHERE cCompanyID = '" & Trim(COID) & "' " & _
                                     "UNION ALL " & _
                                     "SELECT cTranno, cName " & _
                                     "FROM VOUTPC " & _
                                     "WHERE cCompanyID = '" & Trim(COID) & "') A " & _
                                "ORDER BY cTranno", "Voucher ID", "Payment To"
            Case "Check_Released_Date"
                    'GetCheckNumber
                    GetReportID "SELECT cCheckno as ID, cName as Name " & _
                                "FROM Checks " & _
                                "WHERE cCompanyID = '" & Trim(COID) & "' ORDER BY cCheckno", "Check Number", "Name"
            Case "Check_Issuance"
            Case "Inventory_Product_Activity"
                    'GetProductID
                    GetReportID "SELECT cItemno as ID, cDesc as Name " & _
                                "FROM Item A  " & _
                                "WHERE A.cCompanyID = '" & Trim(COID) & "' ORDER BY cItemNo", "Product ID", "Description"
            Case "Inventory_Product_Movement"
                    'GetProductID
                    GetReportID "SELECT cItemno as ID, cDesc as Name " & _
                                "FROM Item A  " & _
                                "WHERE A.cCompanyID = '" & Trim(COID) & "' ORDER BY cItemNo", "Product ID", "Description"
            Case "Inventory_Cost_Of_Good_Sold"
                    'getProductID
                    GetReportID "SELECT cItemno as ID, cDesc as Name " & _
                                "FROM Item A  " & _
                                "WHERE A.cCompanyID = '" & Trim(COID) & "' ORDER BY cItemNo", "Product ID", "Description"
            Case "Inventory_Product_Ranking"
                    'GetProductID
                    GetReportID "SELECT cItemno as ID, cDesc as Name " & _
                                "FROM Item A  " & _
                                "WHERE A.cCompanyID = '" & Trim(COID) & "' ORDER BY cItemNo", "Product ID", "Description"
            Case "DR_Journal_Type"
                    GetReportID "SELECT cDRNo as id, dDate as name " & _
                                "FROM DR A  " & _
                                "WHERE A.cCompanyID = '" & Trim(COID) & "' And " & _
                                "      dDate Between '" & frmReportConditioner.dtITGDateFrom.Text & "' And '" & frmReportConditioner.dtITGDateTo.Text & "' " & _
                                "ORDER BY cDRNo", "D.R. ID", "Date"
            Case "DR_Journal_Product"
                    'GetProductID
                    GetReportID "SELECT cItemno as ID, cDesc as Name " & _
                                "FROM Item A  " & _
                                "WHERE A.cCompanyID = '" & Trim(COID) & "' ORDER BY cItemNo", "Product ID", "Description"
            Case "Inventory_GP_Market_Segment"
                    GetReportID "Select cMSCode as ID, cName as Name " & _
                                "from Client_Customer " & _
                                "Where cCompanyID = '" & Trim(COID) & "' " & _
                                "Order by cMSCode ", "Market Segment", "Client Name"
            Case "Inventory_GP_Salesman"
                    'GetSalesmanID
                    GetReportID "SELECT cCode as ID, cName as Name " & _
                                "FROM Salesman " & _
                                "WHERE cCompanyID = '" & Trim(COID) & "' ORDER BY cCode", "Salesman ID", "Name"
            Case "Inventory_GP_Customer"
                    'GetCustomerID
                    GetReportID "SELECT cCode as ID, cName as Name " & _
                                "FROM Client_Customer " & _
                                "WHERE cCompanyID = '" & Trim(COID) & "' ORDER BY cCode", "Customer ID", "Name"
            Case "Inventory_GP_Item_Customer"
                    'GetCustomerID
                    GetReportID "SELECT cCode as ID, cName as Name " & _
                                "FROM CLIENT_CUSTOMER " & _
                                "WHERE cCompanyID = '" & Trim(COID) & "' ORDER BY cCode", "Customer ID", "Name"
            Case "Inventory_Transfer"
                    GetReportID "Select cTranno as ID, dDate as Name " & _
                                "From Transfer " & _
                                "Where cCompanyID = '" & Trim(COID) & "' And " & _
                                "      dDate Between '" & frmReportConditioner.dtITGDateFrom.Text & "' And '" & frmReportConditioner.dtITGDateTo.Text & "' " & _
                                "Order by cTranno ", "Transfer ID", "Date"
            Case "Listing_Customer"
                    'GetCustomerID
                    GetReportID "SELECT cCode as ID, cName as Name " & _
                                "FROM CLIENT_CUSTOMER " & _
                                "WHERE cCompanyID = '" & Trim(COID) & "' ORDER BY cCode", "Customer ID", "Name"
            Case "Listing_Supplier"
                    'GetSupplierID
                    GetReportID "SELECT cCode as ID, cName as Name " & _
                                "FROM Client_Supplier " & _
                                "WHERE cCompanyID = '" & Trim(COID) & "' ORDER BY cCode", "Supplier ID", "Name"
            Case "Listing_Product"
                    'GetProductID
                    GetReportID "SELECT cItemno as ID, cDesc as Name " & _
                                "FROM Item A  " & _
                                "WHERE A.cCompanyID = '" & Trim(COID) & "' ORDER BY cItemNo", "Product ID", "Description"
            Case "Listing_Salesman"
                    'GetSalesmanID
                    GetReportID "SELECT cCode as ID, cName as Name " & _
                                "FROM Salesman " & _
                                "WHERE cCompanyID = '" & Trim(COID) & "' ORDER BY cCode", "Salesman ID", "Name"
            Case "Listing_Fixed_Asset"
                    'GetSalesmanID
                    GetReportID "SELECT cAssetNo as ID, cDesc as Name " & _
                                "FROM Asset " & _
                                "WHERE cCompanyID = '" & Trim(COID) & "' ORDER BY cAssetno", "Asset ID", "Description"
            Case "Listing_Fixed_Asset"
                    'GetSalesmanID
                    GetReportID "SELECT cEWTNo as ID, dDate as Name " & _
                                "FROM EWT " & _
                                "WHERE cCompanyID = '" & Trim(COID) & "' ORDER BY cEWTNo", "EWT ID", "Date"
            Case "Chart_of_Account"
            Case "Trial_Balance"
            Case "Balance_Sheet"
            Case "Income_Statement"
            Case "Bounced_Check_Journal"
                    'GetCheckNumber
                    GetReportID "SELECT cCheckno as ID, cName as Name " & _
                                "FROM Checks " & _
                                "WHERE cCompanyID = '" & Trim(COID) & "' ORDER BY cCheckno", "Check Number", "Name"
            Case "Unreplaced_RTC"
                    'GetCheckNumber
                    GetReportID "SELECT cCheckno as ID, cName as Name " & _
                                "FROM Checks " & _
                                "WHERE cCompanyID = '" & Trim(COID) & "' ORDER BY cCheckno", "Check Number", "Name"
                                
            Case "Deposit_Journal"
                    'GetDepositID
                    GetReportID "SELECT cTranno as ID, dDate as Name " & _
                                "FROM Deposit " & _
                                "WHERE cCompanyID = '" & Trim(COID) & "' And " & _
                                "      dDate Between '" & frmReportConditioner.dtITGDateFrom.Text & "' And '" & frmReportConditioner.dtITGDateTo.Text & "' " & _
                                "ORDER BY cTranno", "Deposit Slip ID", "Date"
            Case "PDC_On_Hand"
                    'GetCheckNumber
                    GetReportID "SELECT cCheckno as ID, cName as Name " & _
                                "FROM Checks " & _
                                "WHERE cCompanyID = '" & Trim(COID) & "' ORDER BY cCheckno", "Check Number", "Name"
            Case "ARAging"
                    'GetCustomerID
                    GetReportID "SELECT cCode as ID, cName as Name " & _
                                "FROM CLIENT_CUSTOMER " & _
                                "WHERE cCompanyID = '" & Trim(COID) & "' ORDER BY cCode", "Customer ID", "Name"
            Case "ARAging_Division"
                    'GetProductDivisionID
                    GetReportID "Select cDepartment as ID, cDesc as Name " & _
                                "From Item " & _
                                "Where cCompanyID = '" & Trim$(COID) & "' Order by cDepartment", "Division ID", "Product Description"
            
            Case "APAging"
                    'GetSupplierID
                    GetReportID "SELECT cCode as ID, cName as Name " & _
                                "FROM Client_Supplier " & _
                                "WHERE cCompanyID = '" & Trim(COID) & "' ORDER BY cCode", "Supplier ID", "Name"
            Case "Daily_Check_Released"
            
                GetReportID "SELECT cCheckno as ID, dDate as Name " & _
                                "FROM Issued_T " & _
                                "WHERE cCompanyID = '" & Trim(COID) & "' ORDER BY cCheckno", "Check Number", "Transaction Date"
            
    End Select

End Sub

Private Sub lvwList_DblClick()
    SelectOK
End Sub

Private Sub SelectOK()

    If lvwList.ListItems.Count = 0 Then Exit Sub
    If lvwList.SelectedItem.Selected = False Then Exit Sub
    cID = lvwList.SelectedItem.Text
    cName = lvwList.SelectedItem.ListSubItems(1)
    Unload Me
End Sub

Private Sub lvwList_KeyPress(KeyAscii As Integer)
    If KeyAscii = 13 Then
        SelectOK
    End If
End Sub

Public Sub GetReportID(cSQL As String, cField1 As String, cField2 As String)
Dim rsPickList As New ADODB.Recordset
cID = ""
cName = ""
        Set itmX = lvwList.ColumnHeaders.Add(, , cField1)
        Set itmX = lvwList.ColumnHeaders.Add(, , cField2)
        lvwList.ColumnHeaders(1).Width = "1500"
        lvwList.ColumnHeaders(2).Width = "3000"
            
        rsPickList.Open cSQL, cn, adOpenForwardOnly, adLockReadOnly, adCmdText
            
        Do Until rsPickList.EOF
            Set itmX = lvwList.ListItems.Add(, , Trim(rsPickList!ID) & "")
            itmX.SubItems(1) = Trim(rsPickList!Name) & ""

            rsPickList.MoveNext
        Loop
End Sub
